﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using MyToDo.Shared.Dtos;
using MyToDo.Shared.Parameters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WPFPrismAPI.Context;
using WPFPrismAPI.Service;

namespace WPFPrismAPI.Controllers
{
    /// <summary>
    /// 登录控制器
    /// </summary>
    [Route("api/[controller]/[action]")]//  api/路由的名字/具体方法的名字
    [ApiController]
    public class LoginController : ControllerBase
    {
        private readonly ILoginService service;

        public LoginController(ILoginService service)
        {
            this.service = service;
        }
        [HttpPost]
        public async Task<ApiResponse> Login([FromBody] UserDto param)
        {
            return await service.LoginAsync(param.Account, param.PassWord);
        }

        [HttpPost]
        public async Task<ApiResponse> Resgiter([FromBody] UserDto param)
        {
            return await service.ResgiterAsync(param);
        }
    }
}
